package com.laiketui.common.mapper;

import com.laiketui.domain.plugin.bargain.BargainRecordModel;
import com.laiketui.core.db.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author Trick
 */
public interface BargainRecordModelMapper extends BaseMapper<BargainRecordModel> {


    /**
     * 统计订单金额
     *
     * @param stroeId -
     * @param orderno -
     * @return BigDecimal
     * @author Trick
     * @date 2021/4/16 16:08
     */
    @Select("select ifnull(sum(money),0) from lkt_bargain_record where store_id=#{stroeId} and order_no =#{orderno}")
    BigDecimal getOrderMoney(int stroeId, String orderno);


    /**
     * 获取好友帮砍记录
     *
     * @param storeId -
     * @param orderno -
     * @return List
     * @author Trick
     * @date 2021/4/19 15:55
     */
    @Select("select a.user_name,a.headimgurl,b.money bargain_money from lkt_user a left join lkt_bargain_record b on a.user_id=b.user_id " +
            " where a.store_id = #{storeId} and a.user_id=b.user_id and b.order_no=#{orderno}")
    List<Map<String, Object>> getFriendBargainList(int storeId, String orderno);
}